<?php
/**
 * Created by PhpStorm.
 * User: HuangLuSen
 * Date: 2017/5/17
 * Time: 14:57
 */

namespace app\admin\model;


use think\Model;

class Customer extends Model
{
    protected $insert = [  'create_time'];
    protected $update  = ['last_login_ip','last_login_time'];
    protected $type = [
        'create_time'  =>  'timestamp',
        'last_login_time'  =>  'timestamp',
    ];
    protected function setLastLoginIpAttr()
    {
        return request()->ip();
    }
    //获取用户属性
    public function getAttrTextAttr($value,$data)
    {
        $status = [154=>'员工',153=>'老顾客'];
        return $status[$data['attr']];
    }
    /**
     * 创建时间
     * @return bool|string
     */
    protected function setCreateTimeAttr()
    {
        return time();
    }
    //获取用户部门(连表)
    public function department(){
        return $this->belongsTo('department','bumen','id',[],"LEFT");
    }
}